package com.helmlabs.grouper.core.dao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.security.GrantedAuthority;
import org.springframework.security.GrantedAuthorityImpl;
import org.springframework.security.context.SecurityContext;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.security.context.SecurityContextImpl;
import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
import org.springframework.security.userdetails.UserDetails;

public class BaseDaoTestCase extends org.springframework.test.AbstractTransactionalDataSourceSpringContextTests {
	
	protected Log log = LogFactory.getLog(getClass());
	
	public void createSecurityContext(UserDetails userDetails){
		SecurityContext context = new SecurityContextImpl();
		GrantedAuthority[] authorities = new GrantedAuthorityImpl[1];
		authorities[0] = new GrantedAuthorityImpl("ROLE_ADMIN");
		UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(userDetails.getUsername(),userDetails.getPassword(),userDetails.getAuthorities());
		token.setDetails(userDetails);
		context.setAuthentication(token);
		SecurityContextHolder.setContext(context);		
	}
	
	public void onSetUp() throws Exception {
		super.onSetUp();
	}
	
	public void testApp(){
		assertTrue(true);
	}

}
